package com.example.tool.activtiy;

import android.support.v7.widget.CardView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.tool.R;
import com.example.tool.activtiy.base.BaseActivity;
import com.example.tool.listener.PermissionListener;
import com.example.tool.mvp.CommonPresent;
import com.example.tool.util.DebugLog;
import com.example.tool.util.FileUtil;
import com.example.tool.util.PermissionUtil;
import com.example.tool.widget.love.LoveLayout;

import java.io.File;
import java.util.List;

import butterknife.BindView;

/**
 * 描述:文件操作类
 *
 * @author: liangkun
 * @date: 2019/10/9 17:10
 */
public class FileToolActivity extends BaseActivity<CommonPresent> {
    @BindView(R.id.tv_title)
    protected TextView tvTitle;
    @BindView(R.id.card_file_creat)
    protected CardView btnCreat;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_file_tool;
    }

    @Override
    protected void initView() {
        tvTitle.setText("文件工具类");
        requestPermisson();
    }

    private void requestPermisson() {
        PermissionUtil.requestPermission(new PermissionListener() {
            @Override
            public void onGranted() {
                DebugLog.d(DebugLog.FILE_TOOL + " requestPermisson---- ");
                String dir = FileUtil.getInstance().getSdcardPath() + File.separator + "PMP";
                FileUtil.getInstance().createFileDir(dir);
            }

            @Override
            public void onDenied(List<String> deniedPermissions) {

            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initEvent() {
        btnCreat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String file = FileUtil.getInstance().getSdcardPath() + File.separator + "PMP"
                        + File.separator + "Aion.txt";
                boolean isCreat = FileUtil.getInstance().createFile(file);
                DebugLog.d(DebugLog.FILE_TOOL + " 創建=--- isCreat " + isCreat);

            }
        });
    }

    @Override
    protected CommonPresent createPresenter() {
        return null;
    }
}
